cc.Class({
    extends: cc.Component,

    properties: {
        // foo: {
        //    default: null,
        //    url: cc.Texture2D,  // optional, default is typeof default
        //    serializable: true, // optional, default is true
        //    visible: true,      // optional, default is true
        //    displayName: 'Foo', // optional
        //    readonly: false,    // optional, default is false
        // },
        // ...
        _club:null,
        _clubViewlist:null,
        _clubContent:null,
        _clubViewitem:null,
        _shenqingViewlist:null,
        _shenqingContent:null,
        _shenqingViewitem:null,
        _julebuCont:null,
        _renyuanViewlist:null,
        _renyuanContent:null,
        _renyuanViewitem:null,
        _fangjianViewlist:null,
        _fangjianContent:null,
        _fangjianViewitem:null,
        _roomCont:null,
        _yaoqing:null,
        // 当前点击房间信息
        nowRoomData:null,
        // 最后所在俱乐部信息
        nowClubData:null,
        // 是否被滚动限制时间内
        isScroll:null,
        // 人员信息
        manListData:null,
        playSprite: {
            default:null,
            type:cc.SpriteFrame
        },
        waitSprite: {
            default:null,
            type:cc.SpriteFrame
        },
        kongSprite: {
            default:null,
            type:cc.SpriteFrame
        },
        _creatRoom:null
    },

    // use this for initialization
    onLoad: function () {
        console.log("ClubOnload");
        cc.vv.club=this;
        cc.vv.club.isScroll={};
        cc.vv.club.manListData={};
        cc.vv.club.initView();
        cc.vv.club.initEventHandlers()
    },
    initView:function(){
        console.log("initView");
        cc.vv.club._club=cc.vv.club.node.getChildByName("julebu");

        cc.vv.club._creatRoom=cc.vv.club.node.getChildByName("CreateRoom");

        var joinBt = cc.vv.club._club.getChildByName("btn_join");
        cc.vv.club.addClickEvent(joinBt,cc.vv.club.node,"Club","onJoinClubClick");
        var backHallBt = cc.vv.club._club.getChildByName("btn_back");
        cc.vv.club.addClickEvent(backHallBt,cc.vv.club.node,"Club","onBackHallClick");
        // 俱乐部列表
        cc.vv.club._clubViewlist = cc.vv.club._club.getChildByName("julebulist");
        cc.vv.club._clubContent = cc.find("view/content",cc.vv.club._clubViewlist);
        cc.vv.club._clubViewitem = cc.vv.club._clubContent.children[0];
        cc.vv.club._clubContent.removeChild(cc.vv.club._clubViewitem);
        // 申请记录
        cc.vv.club._shenqingViewlist = cc.vv.club._club.getChildByName("shenqinglist");
        cc.vv.club._shenqingContent = cc.find("view/content",cc.vv.club._shenqingViewlist);
        cc.vv.club._shenqingViewitem = cc.vv.club._shenqingContent.children[0];
        cc.vv.club._shenqingContent.removeChild(cc.vv.club._shenqingViewitem);
        // 某个俱乐部内部
        cc.vv.club._julebuCont=cc.vv.club._club.getChildByName("julebuCont");
        var backBt = cc.vv.club._julebuCont.getChildByName("back");
        cc.vv.club.addClickEvent(backBt,cc.vv.club.node,"Club","onBtnBackClicked");
        var returnBt = cc.vv.club._julebuCont.getChildByName("backRoom");
        cc.vv.club.addClickEvent(returnBt,cc.vv.club.node,"Club","onReturnGameClicked");
        var createBt = cc.vv.club._julebuCont.getChildByName("createRoom");
        cc.vv.club.addClickEvent(createBt,cc.vv.club.node,"Club","onCreateRoomClicked");
            // 人员列表
        cc.vv.club._renyuanViewlist = cc.vv.club._julebuCont.getChildByName("renyuan");
            // 添加滚动刷新
        cc.vv.utils.addScrollEvent(cc.vv.club._renyuanViewlist,this.node,"Club","onScroll");
        cc.vv.club._renyuanContent = cc.find("view/content",cc.vv.club._renyuanViewlist);
        cc.vv.club._renyuanViewitem = cc.vv.club._renyuanContent.children[0];
        cc.vv.club._renyuanContent.removeChild(cc.vv.club._renyuanViewitem);
            // 房间列表
        cc.vv.club._fangjianViewlist = cc.vv.club._julebuCont.getChildByName("fangjian");
        cc.vv.club._fangjianContent = cc.find("view/content",cc.vv.club._fangjianViewlist);
        cc.vv.club._fangjianViewitem = cc.vv.club._fangjianContent.children[0];
        //注销掉
        cc.vv.club._fangjianContent.removeChild(cc.vv.club._fangjianViewitem);
        // 具体房间信息
        cc.vv.club._roomCont=cc.vv.club._fangjianViewlist.getChildByName("fangjianCont");
        var RoombackBt = cc.vv.club._roomCont.getChildByName("back_bt");
        cc.vv.club.addClickEvent(RoombackBt,cc.vv.club.node,"Club","onBtnBackClicked");
        var joinBt = cc.vv.club._roomCont.getChildByName("join");
        cc.vv.club.addClickEvent(joinBt,cc.vv.club.node,"Club","onJoinGame");
        // 邀请信息
        cc.vv.club._yaoqing=cc.vv.club._club.getChildByName("yaoqing");
        var yaoqingbackBt = cc.vv.club._yaoqing.getChildByName("back_bt");
        cc.vv.club.addClickEvent(yaoqingbackBt,cc.vv.club.node,"Club","onBtnBackClicked");
        var joinGameBt = cc.vv.club._yaoqing.getChildByName("join");
        cc.vv.club.addClickEvent(joinGameBt,cc.vv.club.node,"Club","onJoinGame");
        var ignoreBt = cc.vv.club._yaoqing.getChildByName("ignore");
        cc.vv.club.addClickEvent(ignoreBt,cc.vv.club.node,"Club","onignoreBtClick");
        // 暂时做效果
        var chatBt = cc.vv.club._julebuCont.getChildByName("chat");
        cc.vv.club.addClickEvent(chatBt,cc.vv.club.node,"Club","initYaoqingDetail")
    },
    initEventHandlers:function(){
        // var self=this;
        console.log("initEventHandlers");
        // 登陆俱乐部,获取俱乐部列表
        cc.vv.JuleNet.addHandler('login_club_result',function(data){
            // {"errcode":0,clublist:[{"clubid":123456,"name":"俱乐部","curnum":100,"maxnum":300}],applylist:["申请记录"]}
            console.log("login_club_result",data);
            if (!cc.vv.club.node) {
                console.log("当前不在俱乐部界面");
                return
            };
            if (data.errcode==0) {
                cc.vv.club.initClubList(data.clublist)
            }else{
                cc.vv.alert.show("提示","获取俱乐部列表失败请退出重新进入俱乐部")
            }
        });
        // 登陆俱乐部,获取俱乐部列表
        cc.vv.JuleNet.addHandler('get_club_list_notify',function(data){
            // {"errcode":0,clublist:[{"clubid":123456,"name":"俱乐部","curnum":100,"maxnum":300}],applylist:["申请记录"]}
            console.log("get_club_list_notify",data);
            if (!cc.vv.club.node) {
                console.log("当前不在俱乐部界面");
                return
            };
            if (data.errcode==0) {
                if(cc.vv.gameNetMgr.clubid){
                    console.log("俱乐部返回 进入");
                    for(var i = 0; i < data.clublist.length; ++i){
                        //获取当前所在俱乐部数据
                        if(data.clublist[i].clubid==cc.vv.gameNetMgr.clubid){
                            cc.vv.club.clubItemClick(data.clublist[i]);
                            break
                        }
                    }
                };
                cc.vv.club.initClubList(data.clublist)
            }else{
                cc.vv.alert.show("提示","获取俱乐部列表失败请退出重新进入俱乐部")
            }
        });
        // 登陆俱乐部,获取申请列表
        cc.vv.JuleNet.addHandler('apply_list_notify',function(data){
            // {"errcode":0,clublist:[{"clubid":123456,"name":"俱乐部","curnum":100,"maxnum":300}],applylist:["申请记录"]}
            console.log("apply_list_notify",data);
            if (!cc.vv.club.node) {
                console.log("当前不在俱乐部界面");
                return
            };
            if (data.errcode==0) {
                cc.vv.club.initShenqingList(data.applylist)
            }else{
                cc.vv.alert.show("提示","获取申请记录失败请退出重新进入俱乐部")
            }
        });
        // 申请俱乐部返回
        cc.vv.JuleNet.addHandler('apply_club_notify',function(data){
            // {"errcode":0,"errmsg":"申请已提交"}
            console.log("apply_club_notify",data);
            if (data.errcode==0) {
                // cc.vv.club.initShenqingList(data);
                cc.vv.alert.show("提示",data.errmsg);
                // 拉取申请记录
                cc.vv.JuleNet.send("apply_list")
            }else{
                cc.vv.alert.show("提示",data.errmsg)
            }
        });
        // 进入某个俱乐部返回
        cc.vv.JuleNet.addHandler('enter_club_notify',function(data){
            // {"errcode":0,"roomlist":[{"roomid":888888,"status":0,"type":0,"seat":[{"name":端木,"headimg":"url"}]}]}
            console.log("enter_club_notify",data);
            if (!cc.vv.club.node) {
                console.log("当前不在俱乐部界面");
                return
            };
            if (data.errcode==0) {
                // 俱乐部房间列表
                cc.vv.club.initRoomList(data.roomlist)    
            }else{
                cc.vv.alert.show("提示","俱乐部列表获取失败请退出重进")
            }
        });
        // 房间列表推送
        cc.vv.JuleNet.addHandler('room_modify_push',function(data){
            // {"roomlist":[{"roomid":888888,"status":0,"type":0,conf:{}，"seat":[{"name":端木,"headimg":"url"}]}]}
            console.log("room_modify_push",data);
            if (!cc.vv.club.node) {
                console.log("当前不在俱乐部界面");
                return
            };
            // 如果是当前俱乐部，则拉取最新房间列表
            if (!cc.vv.club.nowClubData) {
                console.log("当前不在变动俱乐部内");
                return
            };
            if (data.clubid==cc.vv.club.nowClubData.clubid) {
                console.log("当前所在俱乐部界面有房间变动");
                cc.vv.JuleNet.send("enter_club",{clubid:cc.vv.club.nowClubData.clubid})
            }
        });
        // 俱乐部成员消息
        cc.vv.JuleNet.addHandler('get_club_member_notify',function(data){
            // {"errcode":0,"num":10，"member":[{"name":端木,"headimg":"url","sex":0,"status":0}]}
            console.log("get_club_member_notify",data);
            if (!cc.vv.club.node) {
                console.log("当前不在俱乐部界面");
                return
            };
            if (data.errcode==0) {
                // 没数据则返回（超过俱乐部成员页数拿不到数据）
                if (!data.memberlist) {
                    console.log("当前页数没有成员");
                    return
                };
                // 保存人员信息，根据page更新数据
                cc.vv.club.manListData[cc.vv.club.nowClubData.clubid][data.page]=data.memberlist;
                // 俱乐部房间列表
                cc.vv.club.initManList(data.memberlist,data.page)
            }else{
                cc.vv.alert.show("提示","成员列表获取失败请退出重进")
            }
        })
    },
    addClickEvent:function(node,target,component,handler){
        // console.log("初始化点击事件",handler);
        var eventHandler = new cc.Component.EventHandler();
        eventHandler.target = target;
        eventHandler.component = component;
        eventHandler.handler = handler;
        var clickEvents = node.getComponent(cc.Button).clickEvents;
        clickEvents.push(eventHandler)
    },
    // 返回房间
    onReturnGameClicked:function(){
        console.log("onReturnGameClicked");
        cc.director.loadScene("mjgame")
    },
    // 创建房间
    onCreateRoomClicked:function(){
        console.log("onCreateRoomClicked");
        if(cc.vv.gameNetMgr.roomId != null){
            cc.vv.alert.show("提示","房间已经创建!\n必须解散当前房间才能创建新的房间");
            return
        };
        cc.vv.userMgr.isCreate=true;
        cc.vv.club._creatRoom.active = true
    },
    // 统一的返回按钮
    onBtnBackClicked:function(event){
        console.log("onBtnBackClicked");
        event.target.parent.active=false
    },
    // 申请俱乐部按钮
    onJoinClubClick:function(event){
        // 获取输入框内容
        var data=event.target.parent.getChildByName("input").getComponent(cc.EditBox).string;
        console.log("onJoinClubClick",data);
        if (data.length<6) {
            cc.vv.alert.show("提示","请输入正确六位数俱乐部ID");
            return
        };
        cc.vv.JuleNet.send("apply_club",{clubid:data})
    },
    // 返回大厅按钮
    onBackHallClick:function(){
        console.log("onBackHallClick");
        cc.vv.club._club.active=false
    },
    // 加入游戏房间按钮
    onJoinGame:function(event){
        console.log("onJoinGame",cc.vv.club.nowRoomData.roomData);
        var roomId=cc.vv.club.nowRoomData.roomid;
        cc.vv.userMgr.enterRoom(roomId,function(ret){
            if(ret.errcode == 0){
                event.target.parent.active=false
            }else{
                var content = "房间["+ roomId +"]不存在，请重新输入!";
                if(ret.errcode == 4){
                    content = "房间["+ roomId + "]已满!";
                };
                cc.vv.alert.show("提示",content)
            }
        })
    },
    // 忽略按钮
    onignoreBtClick:function(){
        console.log("onignoreBtClick");
        cc.vv.club._yaoqing.active=false;
        cc.vv.JuleNet.send("reject")
    },
    // 下拉刷新人员
    onScroll:function(){
        // console.log("onScroll");
        var scrollData=cc.vv.club._renyuanViewlist.getComponent(cc.ScrollView).getScrollOffset();
        // 通过滚动距离判断处在哪一页，然后拉取数据
        var page= 1;
        // 一页十人，提前刷新下一页
        var Height=cc.vv.club._renyuanViewitem.height*5;
        // console.log("当前滚动取整前",scrollData,"page",scrollData.y/Height);
        if (scrollData.y<0) {
            page=1
        }else{
            page= Math.round(scrollData.y/Height);
            if (page==1) {page=2}
        };
        if (page==0) {page=1};
        // console.log("处理后page",page);
        if (cc.vv.club.isScroll[page]==false) {
            // console.log("当前页限制时间内不能刷新");
            return
        };
        // 下来刷新人员列表
        cc.vv.JuleNet.send("get_club_member",{clubid:cc.vv.club.nowClubData.clubid,page:page});
        // 每一页自带获取开关
        cc.vv.club.initScrollLimit(page)
    },

    // 俱乐部列表点击
    onClubItemClick:function(event){
        console.log("onClubItemClick",event.target.julebuData);
        cc.vv.club.clubItemClick(event.target.julebuData)
    },

    // 俱乐部列表点击
    clubItemClick:function(data){
        console.log("clubItemClick",data);
        cc.vv.club.nowClubData=data;
        cc.vv.club._julebuCont.active=true;
        if(cc.vv.gameNetMgr.roomId == null){
            cc.vv.club._julebuCont.getChildByName("createRoom").active=true
        }else{
            cc.vv.club._julebuCont.getChildByName("createRoom").active=false
        };
        cc.vv.club.getDetailOfClub(data);
        // 进入俱乐部
        cc.vv.JuleNet.send("enter_club",{clubid:cc.vv.club.nowClubData.clubid});
        // 获取俱乐部成员
        cc.vv.JuleNet.send("get_club_member",{clubid:cc.vv.club.nowClubData.clubid,page:1});
      
        // 关闭第一页开关（防止刚进去俱乐部滚动又刷新第一页）
        cc.vv.club.initScrollLimit(1);
        // 记录人员数据到俱乐部名下
        if (!cc.vv.club.manListData[cc.vv.club.nowClubData.clubid]) {
            cc.vv.club.manListData[cc.vv.club.nowClubData.clubid]={}
        };
        // 滚动条回复
        var scrollView=cc.vv.club._renyuanViewlist.getComponent(cc.ScrollView);
        scrollView.scrollToTop(0.1)
    },
    // 房间列表点击
    onRoomItemClick:function(event){
        console.log("onRoomItemClick",event.target.roomData);
        cc.vv.club._roomCont.active=true;
        cc.vv.club.nowRoomData=event.target.roomData;
        if (cc.vv.gameNetMgr.roomId != null) {
            cc.vv.club._roomCont.getChildByName("join").active=false
        }else{
            cc.vv.club._roomCont.getChildByName("join").active=true
        };
        cc.vv.club.initRoomDetail(cc.vv.club.nowRoomData)
    },
    // 刷新滚动开关(开启当前页限制五秒，打开其他页限制)
    initScrollLimit:function(page){
        // console.log("initScrollLimit开启当前页限制",page)
        cc.vv.club.isScroll[page]=false;
        // 开启其他页码开关(防止还在限制时间内不能刷新)
        for (var key in cc.vv.club.isScroll) {
            if (key!=page) {
                // console.log("关闭其他页限制",key)
                cc.vv.club.isScroll[key]=true
            }
        };
        setTimeout(function(){
            if (!cc.vv.club.isScroll) {return};
            // console.log("关闭当前页限制",page)
            cc.vv.club.isScroll[page]=true
        },5000)
    },
    // 刷新俱乐部列表
    initClubList:function(data){
        console.log("initClubList",data);
        if (!data) {return};
        for(var i = 0; i < data.length; ++i){
            if (!data[i]) {return};
            var node = cc.vv.club.getViewItem(cc.vv.club._clubContent,cc.vv.club._clubViewitem,i,0);
            node.active=true;
            node.julebuData=data[i];
            node.getChildByName("name").getComponent(cc.Label).string = data[i].name;
            node.getChildByName("id").getComponent(cc.Label).string = "ID:"+data[i].clubid;
            node.getChildByName("num").getComponent(cc.Label).string = "人数:"+data[i].curmem;
            // 添加点击俱乐部框事件
            var clickEvent=node.getComponent(cc.Button).clickEvents;
            if (clickEvent.length==0) {
                cc.vv.club.addClickEvent(node,cc.vv.club.node,"Club","onClubItemClick")
            }
        };
        var tishi=cc.vv.club._club.getChildByName("tishi1");
        if( data.length > 0){
            tishi.active = false
        }else{
            console.log("还没有俱乐部");
            tishi.active = true
        };
        cc.vv.club.shrinkContent(cc.vv.club._clubContent,data.length)
    },
    // 刷新申请列表
    initShenqingList:function(data){
        console.log("initShenqingList",data);
        if (!data) {return};
        // var data=[];
        for(var i = 0; i < data.length; ++i){
            if (!data[i]) {return};
            var node = cc.vv.club.getViewItem(cc.vv.club._shenqingContent,cc.vv.club._shenqingViewitem,i,0);
            // node.idx = i;
            node.active=true;
            if (data[i].status==0) {
                str="待审核"
            }else if (data[i].status==1) {
                str="已成功"
            }else{
                str="被拒绝"
            };
            node.getChildByName("clubid").getComponent(cc.Label).string = data[i].name+"  (ID:"+data[i].clubid+")  ";
            var result=node.getChildByName("result");
            var str="";
            if (data[i].status==0) {
                str="待审核";
                result.color=new cc.Color(249, 195, 33)
            }else if (data[i].status==1) {
                str="已成功";
                result.color=new cc.Color(44, 214, 72)
            }else{
                str="被拒绝";
                result.color=new cc.Color(227, 29, 29)
            };
            result.getComponent(cc.Label).string = str
        };
        // console.log("data....."+data);
        var tishi=cc.vv.club._club.getChildByName("tishi2");
        if( data.length > 0){
            tishi.active = false
        }else{
            console.log("还没有申请记录");
            tishi.active = true
        };
        cc.vv.club.shrinkContent(cc.vv.club._shenqingContent,data.length)
    },
    // 刷新人员列表
    initManList:function(data,page){
        console.log("initManList",data,"page",page);
        if (!page) {
            page=1
        };
        if (!data) {return};
       
        for(var i = 0; i < data.length; ++i){
            if (!data[i]) {return};
            var node = cc.vv.club.getViewItem(cc.vv.club._renyuanContent,cc.vv.club._renyuanViewitem,i,(page-1)*10);
            // node.idx = i;
            node.active=true;
            node.getChildByName("name").getComponent(cc.Label).string = data[i].name;;
            var zhuangtai=node.getChildByName("zhuangtai").getComponent(cc.Label);
            if (data[i].status==1) {
                zhuangtai.string="在线";
                zhuangtai.node.color = new cc.Color(32, 234, 51)
            }else if (data[i].status==2) {
                zhuangtai.string="游戏中";
                zhuangtai.node.color = new cc.Color(32, 234, 51)
            }else{
                zhuangtai.string="离线";
                zhuangtai.node.color = new cc.Color(132, 134, 132)
            };
            if (data[i].headimg) {
                // console.log("获取头像");
                node.getChildByName("icon").getComponent("ImageLoader").setUserID(data[i].userid)
            }
        };
        // 按已经有的人员数据，清楚多余数据
        var dataLenght=0;
        for (var key in cc.vv.club.manListData[cc.vv.club.nowClubData.clubid]) {
            var value=cc.vv.club.manListData[cc.vv.club.nowClubData.clubid][key];
            dataLenght+=value.length
        };
        console.log("当前俱乐部已经获取过的人员数量",dataLenght);
        cc.vv.club.shrinkContent(cc.vv.club._renyuanContent,dataLenght)
    },
    // 刷新房间列表
    initRoomList:function(data){
        console.log("initRoomList",data);
        // 记录等待和游戏中数量
        cc.vv.club._fangjianViewlist.dengnum=0;
        cc.vv.club._fangjianViewlist.playnum=0;
        // cc.vv._fangjianContent=cc.vv.club._fangjianContent;
        for(var i = 0; i < data.length; ++i){
            if (!data[i]) {return};
            cc.vv.club.initSingleRoom(data[i],i)
        };
        cc.vv.club.initRoomNum();
        cc.vv.club.shrinkContent(cc.vv.club._fangjianContent,data.length)
    },
    // 刷新房间列表基本信息
    initRoomNum:function(){
        console.log("initRoomNum");
        cc.vv.club._fangjianViewlist.getChildByName("dengdaiNum").getComponent(cc.Label).string="等待中:"+cc.vv.club._fangjianViewlist.dengnum;
        cc.vv.club._fangjianViewlist.getChildByName("youxiNum").getComponent(cc.Label).string="游戏中:"+cc.vv.club._fangjianViewlist.playnum
    },
    // 刷新单个房间
    initSingleRoom:function(data,idnex){
        console.log("initSingleRoom",data,"idnex",idnex);
        if (!data) {
            console.log("无房间数据")
            return
        };
        var node = cc.vv.club.getViewItem(cc.vv.club._fangjianContent,cc.vv.club._fangjianViewitem,idnex,0);
        node.roomData=data;
        if (data.type==10) {
            data.type="牌九"
        };
        node.getChildByName("type").getComponent(cc.Label).string = data.type;
        var zhuangtai=node.getChildByName("zhuangtai").getComponent(cc.Sprite);
        if (data.status==1) {
            zhuangtai.spriteFrame=cc.vv.club.playSprite;
            cc.vv.club._fangjianViewlist.playnum++
        }else{
            cc.vv.club._fangjianViewlist.dengnum++;
            zhuangtai.spriteFrame=cc.vv.club.waitSprite
        };
        var seatData = data.seats;
        var seats=node.getChildByName("seats");
        for(var j = 0; j < seats.childrenCount; ++j){
            var  seatNode=seats.children[j];
            if (seatData[j]&&seatData[j].name!="") {
                if (seatData[j].userId) {
                    seatNode.getComponent("ImageLoader").setUserID(seatData[j].userId)
                }
            }else{
                // 回复空头像
                seatNode.getComponent("cc.Sprite").spriteFrame=this.kongSprite
            }
        };
        // 添加点击房间框事件
        var clickEvent=node.getComponent(cc.Button).clickEvents;
        if (clickEvent.length==0) {
            cc.vv.club.addClickEvent(node,cc.vv.club.node,"Club","onRoomItemClick")
        }    
    },
    // 单个房间具体信息
    initRoomDetail:function(data){
        console.log("initRoomDetail",data);
        // 满人或已经开始则不显示进入按钮
        var seatNum=0;
        for (var i = data.seats.length - 1; i >= 0; i--) {
            if (data.seats[i].name!="") {
                seatNum++
            }
        };
        if (seatNum==4||data.status==1||cc.vv.gameNetMgr.roomId != null) {
            cc.vv.club._roomCont.getChildByName("join").active=false
        }else{
            cc.vv.club._roomCont.getChildByName("join").active=true
        };
        if (data.type==10) {
            data.type="牌九"
        };
        cc.vv.club._roomCont.getChildByName("fanghao").getComponent(cc.Label).string=data.roomid;
        cc.vv.club._roomCont.getChildByName("type").getComponent(cc.Label).string=data.type;
        cc.vv.club._roomCont.getChildByName("jushu").getComponent(cc.Label).string=data.conf.maxGames+"局";
        cc.vv.club._roomCont.getChildByName("renshu").getComponent(cc.Label).string=seatNum+"人";
        cc.vv.club._roomCont.getChildByName("wanfa").getComponent(cc.Label).string=cc.vv.gameNetMgr.getWanfa(data.conf)
    },
    // 邀请框
    initYaoqingDetail:function(data){
        cc.vv.club._yaoqing.active=true;
        var data={
            roomId:123456,
            type:"长沙麻将",
            jushu:8,
            renshu:3,
            wanfa:"庄闲 抓4马",
            userid:1,
            mes:"我在享趣俱乐部等你，快来跟我们一起玩长沙麻将吧",
            headimg:""
        };
        console.log("initYaoqingDetail",data);
        cc.vv.club._yaoqing.roomData=data;
        cc.vv.club._yaoqing.getChildByName("mes").getComponent(cc.Label).string=data.mes;
        cc.vv.club._yaoqing.getChildByName("type").getComponent(cc.Label).string="玩法名称:"+data.type;
        cc.vv.club._yaoqing.getChildByName("jushu").getComponent(cc.Label).string="局数:"+data.jushu+"局";
        cc.vv.club._yaoqing.getChildByName("renshu").getComponent(cc.Label).string="人数:"+data.renshu+"人";
        cc.vv.club._yaoqing.getChildByName("wanfa").getComponent(cc.Label).string="玩法:"+data.wanfa;
        if (data.headimg) {
            cc.vv.club._yaoqing.getChildByName("icon").getComponent("ImageLoader").setUserID(data.userid)
        }
    },
    // 获取滚动内容节点
    getViewItem:function(targetCont,targetItem,index,startIndex){
        // console.log("getViewItem");
        if(targetCont.childrenCount-startIndex > index){
            return targetCont.children[index+startIndex]
        };
        var viewitem = cc.instantiate(targetItem);
        targetCont.addChild(viewitem);
        return viewitem
    },
    // 某个俱乐部内部基本信息
    getDetailOfClub:function(data){
        console.log("getDetailOfClub",data);
        if (!data) {
            console.log("无俱乐部数据");
            return
        };
        // 俱乐部基本信息
        if (data.curnum&&data.maxnum) {
            cc.vv.club._julebuCont.getChildByName("fangka").getComponent(cc.Label).string=data.curnum
        };
        if (data.name) {
            cc.vv.club._julebuCont.getChildByName("name").getComponent(cc.Label).string=data.name
        };
        if (data.clubid) {
            cc.vv.club._julebuCont.getChildByName("id").getComponent(cc.Label).string=data.clubid
        };
        if (data.curmem&&data.maxmem) {
            cc.vv.club._julebuCont.getChildByName("num").getComponent(cc.Label).string=data.curmem+"/"+data.maxmem
        }
    },
    // 去除多余滚动内容节点
    shrinkContent:function(targetCont,num){
        while(targetCont.childrenCount > num){
            var lastOne = targetCont.children[targetCont.childrenCount -1];
            targetCont.removeChild(lastOne,true)
        }
    }
    // called every frame, uncomment cc.vv.club function to activate update callback
    // update: function (dt) {

    // },
});
